<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Usermodel extends CI_Model
{
	public function get_menu_for_master($PREVILEGE_ID)
	{
		$this->db->select('master_menu.id,master_menu.parent_id, master_menu.title, master_menu.url, master_menu.target, master_menu.is_submenu');
		$this->db->from('master_menu_navigation');
		$this->db->join('master_menu','master_menu_navigation.menu_id = master_menu.id and master_menu.activate = 1 and master_menu.parent_id = 0');
		$this->db->join('master_user','master_menu_navigation.user_id = master_user.id and master_user.status = 1');
		$this->db->where('master_user.previlege_id',$PREVILEGE_ID);
		$this->db->order_by('master_menu.menu_order','asc');
		$result = $this->db->get();
		return $result;
	}
	
	public function get_menu_for_level($PREVILEGE_ID)
	{
		$MASTER_PARENTID = '0';
		$this->db->select('master_menu.id,master_menu.parent_id, master_menu.title, master_menu.url, master_menu.target');
		$this->db->from('master_menu_navigation');
		$this->db->join('master_menu','master_menu_navigation.menu_id = master_menu.id and master_menu.activate = 1');
		$this->db->join('master_user','master_menu_navigation.user_id = master_user.id and master_user.status = 1');
		$this->db->where('master_user.previlege_id',$PREVILEGE_ID);
		$this->db->where('master_menu.parent_id !=',$MASTER_PARENTID);
		$this->db->order_by('master_menu.menu_order','asc');
		$result = $this->db->get();
		return $result;
	}
	
	function get_array_menu($id)
	{
		$this->db->select('MENU_ORDER');
		$this->db->from('master_menu');
		$this->db->where('ID',$id);
		$data = $this->db->get();
		if($data->num_rows() > 0)
		{
			$row = $data->row();
			$level = $row->MENU_ORDER;
			return $level;
		}
		else
		{
			die();
		}
	}
}